<?php

namespace App\Http\Controllers;

use App\Http\Services\IndexService;
use App\Models\Setting;

class IndexController extends Controller
{
    protected $service;

    public function __construct(IndexService $service)
    {
        $this->service = $service;
    }

    //轮播图
    public function banners()
    {
        $list = $this->service->banners();
        return response()->json(['code'=>200,'data'=>$list]);
    }

    //保险分类
    public function category()
    {
        $is_recommend = request()->get('is_recommend');
        $list = $this->service->category($is_recommend);
        return response()->json(['code'=>200,'data'=>$list]);
    }

    //保险
    public function product()
    {
        $param = request()->input();
        $list = $this->service->product($param);
        return response()->json(['code'=>200,'data'=>$list]);
    }

    //客服图片
    public function kefu()
    {
        $content = Setting::where('id', 8)->value('value');
        $value = Setting::where('id', 1)->value('value');
        $value = env('APP_URL') . '/storage/' . $value;
        return response()->json(['code'=>200,'data'=>$value, 'content'=>$content]);
    }

    //关于我们
    public function aboutUs()
    {
        $value = Setting::where('id', 2)->value('value');
        return response()->json(['code'=>200,'data'=>$value]);
    }
}
